package com.ruoyi.system.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.WebMallUserOrderPay;
import com.ruoyi.system.service.IWebMallUserOrderPayService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 支付订单信息Controller
 * 
 * @author wsliupan@126.com
 * @date 2021-06-19
 */
@Controller
@RequestMapping("/system/userOrderPay")
public class WebMallUserOrderPayController extends BaseController
{
    private String prefix = "system/userOrderPay";

    @Autowired
    private IWebMallUserOrderPayService webMallUserOrderPayService;

    @RequiresPermissions("system:userOrderPay:view")
    @GetMapping()
    public String userOrderPay()
    {
        return prefix + "/userOrderPay";
    }

    /**
     * 查询支付订单信息列表
     */
    @RequiresPermissions("system:userOrderPay:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(WebMallUserOrderPay webMallUserOrderPay)
    {
        startPage();
        List<WebMallUserOrderPay> list = webMallUserOrderPayService.selectWebMallUserOrderPayList(webMallUserOrderPay);
        return getDataTable(list);
    }

    /**
     * 导出支付订单信息列表
     */
    @RequiresPermissions("system:userOrderPay:export")
    @Log(title = "支付订单信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(WebMallUserOrderPay webMallUserOrderPay)
    {
        List<WebMallUserOrderPay> list = webMallUserOrderPayService.selectWebMallUserOrderPayList(webMallUserOrderPay);
        ExcelUtil<WebMallUserOrderPay> util = new ExcelUtil<WebMallUserOrderPay>(WebMallUserOrderPay.class);
        return util.exportExcel(list, "支付订单信息数据");
    }

    /**
     * 新增支付订单信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存支付订单信息
     */
    @RequiresPermissions("system:userOrderPay:add")
    @Log(title = "支付订单信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(WebMallUserOrderPay webMallUserOrderPay)
    {
        return toAjax(webMallUserOrderPayService.insertWebMallUserOrderPay(webMallUserOrderPay));
    }

    /**
     * 修改支付订单信息
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        WebMallUserOrderPay webMallUserOrderPay = null;
        if(id == null || id ==  -1){
            webMallUserOrderPay = new WebMallUserOrderPay();
        }else{
            webMallUserOrderPay = webMallUserOrderPayService.getById(id);
        }
        mmap.put("webMallUserOrderPay", webMallUserOrderPay);
        return prefix + "/edit";
    }

    /**
     * 修改保存支付订单信息
     */
    @RequiresPermissions("system:userOrderPay:edit")
    @Log(title = "支付订单信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(WebMallUserOrderPay webMallUserOrderPay)
    {
        return toAjax(webMallUserOrderPayService.updateWebMallUserOrderPay(webMallUserOrderPay));
    }

    /**
     * 删除支付订单信息
     */
    @RequiresPermissions("system:userOrderPay:remove")
    @Log(title = "支付订单信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(webMallUserOrderPayService.deleteWebMallUserOrderPayByIds(ids));
    }
}
